package com.yjt.gcss.gddw.modules.uiFileLog;

import java.util.Hashtable;

import javax.annotation.Resource;

import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yjt.common.easyui.datagrid.DataGridDTO;
import com.yjt.common.easyui.datagrid.DataGridJsonDTO;
import com.yjt.common.tools.StringUtil;
import com.yjt.common.tools.TimeUtil;
import com.yjt.gcss.gddw.common.bean.domain.UiFileLog;
import com.yjt.gcss.gddw.common.dao.UiFileLogDao;

@Service(UiFileLogService.BEAN_PACKAGE_NAME)
@Transactional(readOnly=true)
public class UiFileLogService {

	public static final String BEAN_PACKAGE_NAME = "com.yjt.gcss.gddw.modules.uiFileLog.UiFileLogService";
	
	@Resource(name = UiFileLogDao.BEAN_PACKAGE_NAME)
	private UiFileLogDao uiFileLogDao;
	
	public DataGridJsonDTO query(UiFileLog queryModel, DataGridDTO _dataGridDto) {
		Hashtable<String, String> paramsTable = new Hashtable<String, String>();
		//交易日期
		if(!StringUtil.isEmpty(queryModel.getQuery_start_date_jyrq())){
			paramsTable.put("query_start_date_jyrq", TimeUtil.changeStrTimeFormat(queryModel.getQuery_start_date_jyrq(), "yyyy-MM-dd", "yyyyMMdd"));
			uiFileLogDao.enableFilter("uiFileLogFilterByJYRQStartDate", paramsTable);
			paramsTable.clear();
		}
		if(!StringUtil.isEmpty(queryModel.getQuery_end_date_jyrq())){
			paramsTable.put("query_end_date_jyrq", TimeUtil.changeStrTimeFormat(queryModel.getQuery_end_date_jyrq(), "yyyy-MM-dd", "yyyyMMdd"));
			uiFileLogDao.enableFilter("uiFileLogFilterByJYRQEndDate", paramsTable);
			paramsTable.clear();
		}
		uiFileLogDao.addOrder(Order.desc("createDate"));
		uiFileLogDao.addOrder(Order.desc("createTime"));
		DataGridJsonDTO result = uiFileLogDao.getBeansByBeanForPager(queryModel, MatchMode.ANYWHERE, _dataGridDto, true);
		uiFileLogDao.disableFilter("uiFileLogFilterByJYRQStartDate");
		uiFileLogDao.disableFilter("uiFileLogFilterByJYRQEndDate");
		return result;
	}
}
